package com.lmx.repoDomain.tmodel;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import com.lmx.repoDomain.tmodel.business.User;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;

@JsonApiResource(type = "nursingplan")
@Table(name = "tnb_nursingplan")
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class NursingPlan extends BaseEntity {

	private User lastUpdateUser;// 更新操作者userid

	private Integer createDateTime;// 创建时间

	private User createUser;

	private Integer lastUpdateDateTime;// 更新时间
	
	private String remark;// 备注

	private Integer planStartTime;//jihua时间
	
	private Integer planEndTime;//计划时间
	
	private Customer customer;
	
	private Dicttype planType;// 方案类型
	
	private Dicttype planDateType;// 方案类型
	
	private Set<NursingPlanServiceItem> services;// 所对应照护项目   从护理方案中选取
	
	
    @JsonApiToMany
    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH,mappedBy = "plan")
	public Set<NursingPlanServiceItem> getServices() {
		return services;
	}

	public void setServices(Set<NursingPlanServiceItem> services) {
		this.services = services;
	}
	
	@Column(name = "planstarttime")
	public Integer getPlanStartTime() {
		return planStartTime;
	}

	public void setPlanStartTime(Integer planStartTime) {
		this.planStartTime = planStartTime;
	}
	
	@Column(name = "planendtime")
	public Integer getPlanEndTime() {
		return planEndTime;
	}

	public void setPlanEndTime(Integer planEndTime) {
		this.planEndTime = planEndTime;
	}

//	@JsonApiToOne
//	@JsonApiIncludeByDefault 
//	@Fetch(FetchMode.JOIN)
//	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
//	@JoinColumn(name = "item_id",foreignKey = @ForeignKey(name = "null"))
//	public CustomerServiceItem getItem() {
//		return item;
//	}
//
//	public void setItem(CustomerServiceItem item) {
//		this.item = item;
//	}
	
	@JsonApiToOne
	//@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "customer_id",foreignKey = @ForeignKey(name = "null"))
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}


	public NursingPlan() {
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}


    @JsonApiToOne
    @JsonApiIncludeByDefault
    @Fetch(FetchMode.JOIN)
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
    @JoinColumn(name = "plantype_id",foreignKey = @ForeignKey(name = "null"))
	public Dicttype getPlanType() {
		return planType;
	}

	public void setPlanType(Dicttype planType) {
		this.planType = planType;
	}
	 
    @JsonApiToOne
    @JsonApiIncludeByDefault
    @Fetch(FetchMode.JOIN)
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
    @JoinColumn(name = "plandatetype_id",foreignKey = @ForeignKey(name = "null"))
	public Dicttype getPlanDateType() {
		return planDateType;
	}

	public void setPlanDateType(Dicttype planDateType) {
		this.planDateType = planDateType;
	}
	
}
